#include <UTILS/SBuffer.h>
#include <PECAgent/PEContext.h>
#include <DPS/PH/DpsFunctions.h>
#include "UDOP_OpGlobalY.h"

SPC_NAMESPACE_USE;
UTILS_NAMESPACE_USE;
using namespace DPS;
using namespace std;
using namespace estd;

/*
 * Function used to initialize the operator
 */
void UDOP_OpGlobalY::initializeOperator() 
{
  // Create a user defined metric
  // opm.createMetric("intuples","Number of ingested tuples");
}

/*
 * Function used to finalize the operator
 */
void UDOP_OpGlobalY::finalizeOperator() 
{
}

/*
 * Function used to process command line arguments
 */
void UDOP_OpGlobalY::processCmdArgs(const string & /*args*/) 
{
  SPCDBG(L_INFO, "Process command line arguments...", "dpsop");
  // ArgContainer arg(args); // include "ArgContainer.h"
  // arg.argc and arg.argv are now available for use
  // do other initialization here
}


/*
 * Process function for input port 0
 */
void UDOP_OpGlobalY::processInput0(const IPort0_t & tuple)
{
  SPCDBG(L_DEBUG, "Processing tuple from input port 0 " << tuple, "dpsop");
  /*
   * OPort0_t otuple; submit0(otuple);
   * // updatePerformanceCounters(opm);
   */
}

/*
 * Punctuate function
 */
/*void UDOP_OpGlobalY::processPunctuation(const Punctuation::Value & value, unsigned int input)
{
  SPCDBG(L_DEBUG, "Processing punctuation from input port " << input, "dpsop");
  // punctuate0(value);
}
*/

/*
 * Function used to notify the operator about the readiness of all ports (this
 * is useful when submitting tuples from within a context other than the process
 * functions of the operator).
 */ 
/*
void UDOP_OpGlobalY::allPortsReady() 
{
} 
*/

/*
 * Terminate function, called asynchronously
 */
/*
void UDOP_OpGlobalY::prepareToTerminate() 
{
}
*/

/*
 * Function used to update performance counters
 */
/*
static void updatePerformanceCounters(DpsOPMetrics & opm) 
{ 
  static long long ntuples = 0;
  // This is not the ideal way of using performance counters
  // Ideally one should store the result from getMetricByName, 
  // in a class member variable. For instance:
  //   DpsMetric & m = opm.getMetricByName("intuples");
  // m could be made a member variable of UDOP_OpGlobalY
  // Then, the following is a more efficient way to use the counter:
  //   m.setValue(ntuples++);
  opm.getMetricByName("intuples").setValue(ntuples++);
}
*/

/*
 * Checkpointing function for saving state, called asynchronously 
 */
/*
void UDOP_OpGlobalY::getCheckpoint(SBuffer & checkpoint) 
{
  SPCDBG(L_DEBUG, "Getting operator state...", "dpsop");
}
*/

/*
 * Checkpointing function for restoring state, called asynchronously
 */
/*
void UDOP_OpGlobalY::restoreCheckpoint(SBuffer & checkpoint) 
{
  SPCDBG(L_DEBUG, "Restoring operator state...", "dpsop");
}
*/


